﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Extensions.cs" company="Matthias Friedrich">
//   Copyright © Matthias Friedrich 2009
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace DeviceManagement
{
	using System;
	using System.Windows.Forms;

	internal static class Extensions
	{
		public static DEV_BROADCAST_HDR GetBroadcastHeader(this Message m)
		{
			return m.GetLParam<DEV_BROADCAST_HDR>();
		}

		public static T GetLParam<T>(this Message m)
		{
			if (m.LParam != IntPtr.Zero)
			{
				return (T)m.GetLParam(typeof(T));
			}

			return default(T);
		}
	}
}